<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>病人列表</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<!-- 引入EasyUI的相关css和js文件 -->
<link href="EasyUI/themes/default/easyui.css" rel="stylesheet"
	type="text/css" />
<link href="EasyUI/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="EasyUI/demo.css" rel="stylesheet" type="text/css" />
<script src="EasyUI/jquery.min.js" type="text/javascript"></script>
<script src="EasyUI/jquery.easyui.min.js" type="text/javascript"></script>
<script src="EasyUI/easyui-lang-zh_CN.js" type="text/javascript"></script>
</head>
<body>
	<script type="text/javascript" charset="UTF-8">
		//新建病案提示框
		function addPrescription() {
			var rows = $("#dg_patientregistrationinfo").datagrid(
					'getSelections');
			if (rows.length > 0) {
				var row = $("#dg_patientregistrationinfo").datagrid(
						"getSelected");
				if (row) {
					$("#dlg_patientcheck").dialog("open").dialog('setTitle',
							'确定病人');
					$("#ff_patientcheck").form("load", {
						"medicalrecord" : row.medicalrecord,
						"patientname" : row.patientname,
						"diagnosticcard" : row.diagnosticcard,
						"state" : row.state,
					});
					urls = "prescription/checkpatient";
				}
			} else {
				$.messager.alert('提示', '请选择病人', 'info');
			}
		}
		function selcetPrescription() {
			var rows = $("#dg_patientregistrationinfo").datagrid(
					'getSelections');
			if (rows.length > 0) {
				var row = $("#dg_patientregistrationinfo").datagrid(
						"getSelected");
				if (row) {
					$("#dlg_patientcheckselect").dialog("open").dialog(
							'setTitle', '确定病人');
					$("#ff_patientcheckselect").form("load", {
						"medicalrecord" : row.medicalrecord,
						"patientname" : row.patientname,
						"diagnosticcard" : row.diagnosticcard,
						"state" : row.state,
					});
					urls = "prescription/queryprescription";
				}
			} else {
				$.messager.alert('提示', '请选择病人', 'info');
			}
		}
		function checkPatient() {
			$("#ff_patientcheck").form("submit", {
				url : urls, //使用参数				
				success : function(result) {
					var result = eval('(' + result + ')');
					$.messager.show({
						title : "提示信息",
						msg : result.message
					});

					if (result.success == 'true') {
						$("#dlg_patientcheck").dialog("close");

						var currentTab = $('#tabs').tabs('getSelected');

						var url1 = 'doctor_work.jsp'

						$("#tabs").tabs('update', {
							tab : currentTab,
							options : {
								title : "新建处方",
								href : url1

							}
						});
						currentTab.panel('refresh');
					}
				}
			});
		}
		function checkPatientSelect() {
			$("#ff_patientcheckselect").form("submit", {
				url : urls, //使用参数				
				success : function(result) {
					var result = eval('(' + result + ')');
					$.messager.show({
						title : "提示信息",
						msg : result.message
					});

					if (result.success == 'true') {
						$("#dlg_patientcheck").dialog("close");

						var currentTab = $('#tabs').tabs('getSelected');

						var url1 = 'select_prescription.jsp'

						$("#tabs").tabs('update', {
							tab : currentTab,
							options : {
								title : "查询处方",
								href : url1

							}
						});
						currentTab.panel('refresh');
					}
				}
			});
		}
		function loadForm() {
			$("#ff_registration").form("load", {
				doctorno : '${sessionScope.registration.doctorno}',
				medicalrecord : '${sessionScope.registration.medicalrecord}',
				waitno : '${sessionScope.registration.waitno}',
			//registrationdate : '${sessionScope.registration.registrationdate}'
			//"registrationdate":,
			//"medicalrecord":,
			})
		}
		$(function() {

			$('#dg_patientregistrationinfo').datagrid({
				singleSelect : false, //设置datagrid为单选
				queryParams : {
					doctorno : '${sessionScope.doctor.doctorno}',
				},
				url : 'registration/querywaitpatient', //为datagrid设置数据源
				//pagination : true, //启用分页
				//pageSize : 10, //设置初始每页记录数（页大小）
				//pageList : [ 10, 15, 20 ], //设置可供选择的页大小
				rownumbers : true, //显示行号
				fit : true, //设置自适应
				toolbar : '#tb_patientinfo',

				header : '#searchtb_patientinfo', //为datagrid标头添加搜索栏
				columns : [ [ { //编辑datagrid的列
					title : '序号',
					field : 'no',
					align : 'center',
					checkbox : true
				}, {
					field : 'diagnosticcard',
					title : '诊疗卡号',
					width : 160
				}, {
					field : 'medicalrecord',
					title : '病案号',
					width : 160
				}, {
					field : 'patientname',
					title : '病人姓名',
					align : 'center',
					width : 80
				}, {
					field : 'state',
					title : '病人状态',
					align : 'center',
					width : 80
				}, {
					field : 'waitno',
					title : '等待号数',

					width : 70
				}, {
					field : 'registrationdate',
					title : '挂号日期',
					width : 160
				} ] ]
			});
		});
		function searchPatient() {
			var search_registrationdate = $('#search_registrationdate')
					.textbox("getValue");
			var search_diagnosticcard = $('#search_diagnosticcard').textbox(
					"getValue");
			var search_doctorno = $('#search_doctorno').textbox("getValue");
			var search_state = "1";

			$("#dg_patientregistrationinfo").datagrid('load', {
				"diagnosticcard" : search_diagnosticcard,
				"registrationdate" : search_registrationdate,

				"doctorno" : search_doctorno
			});
		}
	</script>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center',iconCls:'icon-ok'" title="">
			<div class="easyui-layout" data-options="fit:true">
				<div data-options="region:'north',split:true" style="height: 1px">
					${sessionScope.doctor.doctorno}</div>
				<div data-options="region:'west',split:true" style="width: 800px">
					<!-- 确定病人对话框 -->
					<div id="dlg_patientcheck" class="easyui-dialog" title="确定病人"
						closed="true" style="width: 500px;">
						<div style="padding: 10px 60px 20px 60px">
							<div style="text-align: center; padding: 5px">

								<form id="ff_patientcheck" method="POST" action="">
									<tr>
										<td>病案号:</td>
										<br>
										<td><input class="easyui-textbox" type="text"
											id="medicalrecord" name="medicalrecord"
											data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<tr>
										<td>诊疗卡号:</td>
										<br>
										<td><input class="easyui-textbox" type="text"
											id="diagnosticcard" name="diagnosticcard"
											data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<tr>
										<td>病人姓名:</td>
										<br>
										<td><input class="easyui-textbox" type="text"
											id="patientname" name="patientname"
											data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<tr>
										<td>病人就诊状态:</td>
										<br>
										<td><input class="easyui-textbox" type="text" id="state"
											name="state" data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<br>

								</form>
								<a href="javascript:void(0)" class="easyui-linkbutton"
									onclick="checkPatient();">确定</a>
							</div>
						</div>
					</div>
					<!-- 查询病案对话框 -->
					<div id="dlg_patientcheckselect" class="easyui-dialog"
						title="确定查询病人" closed="true" style="width: 500px;">
						<div style="padding: 10px 60px 20px 60px">
							<div style="text-align: center; padding: 5px">

								<form id="ff_patientcheckselect" method="POST" action="">
									<tr>
										<td>病案号:</td>
										<br>
										<td><input class="easyui-textbox" type="text"
											id="medicalrecord" name="medicalrecord"
											data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<tr>
										<td>诊疗卡号:</td>
										<br>
										<td><input class="easyui-textbox" type="text"
											id="diagnosticcard" name="diagnosticcard"
											data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<tr>
										<td>病人姓名:</td>
										<br>
										<td><input class="easyui-textbox" type="text"
											id="patientname" name="patientname"
											data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<tr>
										<td>病人就诊状态:</td>
										<br>
										<td><input class="easyui-textbox" type="text" id="state"
											name="state" data-options="required:true" readonly="readonly"
											style="width: 100%;"></input></td>
									</tr>
									<br>

								</form>
								<a href="javascript:void(0)" class="easyui-linkbutton"
									onclick="checkPatientSelect();">确定</a>
							</div>
						</div>
					</div>
					<table id="dg_patientregistrationinfo" class="easyui-datagrid"></table>
					<div id="tb_patientinfo" style="padding: 2px 5px;">
						<a href="javascript:void(0)" class="easyui-linkbutton"
							iconCls="icon-add" plain="true" onclick="addPrescription();">新建处方</a>
						<a href="javascript:void(0)" class="easyui-linkbutton"
							iconCls="icon-edit" plain="true" onclick="selcetPrescription();">查询处方</a>
					</div>
					<!-- 创建查询工具栏 -->
					<div id="searchtb_patientinfo" style="padding: 2px 5px;">
						<form id="searchForm_patientinfo" method="post">
							<div style="padding: 3px">
								诊疗卡号&nbsp;&nbsp;<input class="easyui-textbox"
									name="diagnosticcard" id="search_diagnosticcard"
									style="width: 220px" />&nbsp; 医生编号&nbsp;&nbsp;<input
									class="easyui-textbox" name="doctorno" id="search_doctorno"
									value="${sessionScope.doctor.doctorno}" style="width: 110px" />&nbsp;
								<input class="easyui-datebox" label="挂号日期:"
									name="registrationdate" id="search_registrationdate"
									value="<%=new Date().toLocaleString()%>" style="width: 35%;">
							</div>
							<div style="padding: 3px">
								<a href="javascript:void(0)" class="easyui-linkbutton"
									iconCls="icon-search" plain="true" onclick="searchPatient();">查找</a>
							</div>
						</form>
					</div>
				</div>
			</div>
			<div data-options="region:'east',split:true" style="width: 100px">

			</div>
		</div>
	</div>
	</div>
</body>
</html>